package org.xenon.vote.model.pojo.po;

import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 投票的每个选项
 */
public class Choice implements Comparable<Choice>{

    @NotNull
    private int id;//ID

    /**
     * 投票号
     */
    @NotNull(message = "countId.null")
    private int turn;

    /**
     * 选项内容
     */
    @NotNull(message = "detail.null")
    @NotBlank(message = "detail.blank")
    private String detail;

    /**
     * 选项编号
     */
    @NotNull(message = "order.null")
    private int order;

    /**
     * 所有者邮箱
     */
    @NotNull(message = "mail.null")
    @NotBlank(message = "mail.blank")
    @Email(message = "mail.format")
    @Max(value = 128)
    private String owner;

    @NotNull
    private int score;//得票

    public Choice(@NotNull int id,
                  @NotNull(message = "countId.null") int turn,
                  @NotNull(message = "detail.null")
                  @NotBlank(message = "detail.blank") String detail,
                  @NotNull(message = "order.null") int order,
                  @NotNull(message = "mail.null")
                  @NotBlank(message = "mail.blank")
                  @Email(message = "mail.format")
                  @Max(value = 128) String owner,
                  @NotNull int score) {
        this.id = id;
        this.turn = turn;
        this.detail = detail;
        this.order = order;
        this.owner = owner;
        this.score = score;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getTurn() {
        return turn;
    }

    public void setTurn(int turn) {
        this.turn = turn;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    @Override
    public int compareTo(@org.jetbrains.annotations.NotNull Choice o) {
        return this.order - o.order;
    }
}
